#ifndef IMAGEVIEWAREA_H
#define IMAGEVIEWAREA_H

#include <QGraphicsView>
#include "Tools/ToolState.h"

class QGraphicsScene;

class ImageViewArea : public QGraphicsView
{
    Q_OBJECT

public:
    ImageViewArea(QWidget *parent = Q_NULLPTR);
    virtual ~ImageViewArea();

private:
    void initWidget();
    void zoomIn();
    void zoomOut();
    void zoom(float scaleFactor);
    void translate(QPointF delta);

signals:
    void cursorPosChanged(QPoint& cursorpos);

protected:
    // Event handlers
    virtual void mousePressEvent(QMouseEvent *event);
    virtual void mouseReleaseEvent(QMouseEvent *event);
//    virtual void mouseDoubleClickEvent(QMouseEvent *event);
    virtual void wheelEvent(QWheelEvent *event);
    virtual void mouseMoveEvent(QMouseEvent *event);

public:
    void updateImageViewArea();

    void setEnCurToolState(const ToolState &enCurToolState);

private:
    void genAllPointsWhileMoving(const QPointF& start, const QPointF& end, QVector<QPointF>& allpoints);

private:
    ToolState m_enCurToolState;

    QGraphicsScene* m_pGraphicsScene;

    qreal m_zoomDelta;
    qreal m_scale;

    Qt::MouseButton m_translateButton;
    qreal m_translateSpeed;
    bool m_bMouseTranslate;
    QPoint m_lastMousePos;
};

#endif // IMAGEVIEWAREA_H
